<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">

<h:head></h:head>
<body>
	<!-- Listar Evento -->
	<p:panel id="painelListarEvento" widgetVar="painelListarEvento"
		visible="true" closable="true" closeSpeed="0" style="border: none">
		<h:form id="formListarEvento">
			<p:commandLink update=":formIncluirEvento"
				action="#{eventoBean.limparEvento}"
				oncomplete="PF('painelListarEvento').close(); PF('painelIncluirEvento').show();">
				<h:outputText value="Incluir Evento" />
			</p:commandLink>
			<p:dataTable style="width: 50%;" value="#{eventoBean.eventos}"
				var="evento" emptyMessage="" id="tableCli" paginator="true" rows="7"
				paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
				rowsPerPageTemplate="7,14,21">

				<p:column>
					<f:facet name="header">
						<h:outputText value="Nome" />
					</f:facet>
					<h:outputText value="#{evento.nome}" />
				</p:column>
				<p:column>
					<f:facet name="header">
						<h:outputText value="Data de Início" />
					</f:facet>
					<h:outputText value="#{evento.dataInicio.time}">
						<f:convertDateTime type="both" pattern="dd/MM/yyyy" />
					</h:outputText>
				</p:column>
				<p:column>
					<p:commandButton value="Consultar" update=":formConsultarEvento"
						oncomplete="PF('painelConsultarEvento').show(); PF('painelListarEvento').close();">
						<f:setPropertyActionListener target="#{eventoBean.evento}"
							value="#{evento}"></f:setPropertyActionListener>
					</p:commandButton>
				</p:column>
				<p:column>
					<p:commandButton value="Alterar" update=":formAlterarEvento"
						oncomplete="PF('painelAlterarEvento').show(); PF('painelListarEvento').close();">
						<f:setPropertyActionListener target="#{eventoBean.evento}"
							value="#{evento}"></f:setPropertyActionListener>
					</p:commandButton>
				</p:column>
				<p:column>
					<p:commandButton value="Excluir"
						action="#{eventoBean.excluirEvento}" update=":formListarEvento">
						<f:setPropertyActionListener target="#{eventoBean.evento}"
							value="#{evento}"></f:setPropertyActionListener>
						<p:confirm header=""
							message="Tem certeza que deseja efetuar esta exclusão ?"
							icon="ui-icon-alert" />
					</p:commandButton>
				</p:column>
			</p:dataTable>
		</h:form>
	</p:panel>

	<!-- Incluir Evento -->
	<p:panel id="painelIncluirEvento" widgetVar="painelIncluirEvento"
		visible="false" closable="true" closeSpeed="0" style="border: none">
		<h:form id="formIncluirEvento">
			<p:panel style="width: 50%;">
				<table>
					<tr>
						<td><h:outputLabel value="Nome: " /></td>
						<td><p:inputText id="nomeEventoIncl"
								value="#{eventoBean.evento.nome}" /></td>
					</tr>
					<tr>
						<td><h:outputLabel value="Data Início: " /></td>
						<td><p:calendar id="dataIniEventoIncl"
								value="#{eventoBean.dataInicio}" pattern="dd/MM/yyyy"
								locale="pt" showOn="button" /></td>
					</tr>
					<tr>
						<td><h:outputLabel value="Data Término: " /></td>
						<td><p:calendar id="dataTerEventoIncl"
								value="#{eventoBean.dataTermino}" pattern="dd/MM/yyyy"
								locale="pt" showOn="button" /></td>
					</tr>
					<tr>
						<td><h:outputLabel value="Descrição: " /></td>
						<td><p:inputTextarea rows="3" cols="25" id="descricaoEventoIncl"
								value="#{eventoBean.evento.descricao}" /></td>
					</tr>
				</table>
			</p:panel>

			<div class="posicao_botao" align="right">
				<p:commandButton value="Voltar" update=":formListarEvento"
					onclick="PF('painelIncluirEvento').close(); PF('painelListarEvento').show();"
					type="button" />
				<p:commandButton value="Enviar" id="botao"
					action="#{eventoBean.incluirEvento}" styleClass="botao"
					update=":formListarEvento"
					oncomplete="PF('painelIncluirEvento').close(); PF('painelListarEvento').show();" />
			</div>
		</h:form>
	</p:panel>

	<!-- Alterar Evento -->
	<p:panel id="painelAlterarEvento" widgetVar="painelAlterarEvento"
		visible="false" closable="true" closeSpeed="0" style="border: none">
		<h:form id="formAlterarEvento">
			<p:panel style="width: 50%;">
				<table>
					<tr>
						<td><h:outputLabel value="Nome: " /></td>
						<td><p:inputText value="#{eventoBean.evento.nome}" /></td>
					</tr>
					<tr>
						<td><h:outputLabel value="Data Início: " /></td>
						<td><p:calendar value="#{eventoBean.dataInicio}"
								pattern="dd/MM/yyyy" locale="pt" showOn="button" /></td>
					</tr>
					<tr>
						<td><h:outputLabel value="Data Término: " /></td>
						<td><p:calendar value="#{eventoBean.dataTermino}"
								pattern="dd/MM/yyyy" locale="pt" showOn="button" /></td>
					</tr>
					<tr>
						<td><h:outputLabel value="Descrição: " /></td>
						<td><p:inputText value="#{eventoBean.evento.descricao}" /></td>
					</tr>
				</table>
			</p:panel>

			<div class="posicao_botao" align="right">
				<p:commandButton value="Voltar" update=":formListarEvento"
					onclick="PF('painelAlterarEvento').close(); PF('painelListarEvento').show();"
					type="button" />
				<p:commandButton value="Enviar" id="botao"
					action="#{eventoBean.atualizarEvento}" styleClass="botao"
					update=":formListarEvento"
					oncomplete="PF('painelAlterarEvento').close(); PF('painelListarEvento').show();" />
			</div>
		</h:form>
	</p:panel>

	<!-- Consultar Evento -->
	<p:panel id="painelConsultarEvento" widgetVar="painelConsultarEvento"
		visible="false" closable="true" closeSpeed="0" style="border: none">
		<h:form id="formConsultarEvento">
			<p:panel style="width: 50%;">
				<h2>
					<h:outputText value="#{eventoBean.evento.nome}" />
				</h2>
				<table border="1" class="tableConsulta" cellpadding="10">
					<tr>
						<td><h:outputText value="Data de Início: " /></td>
						<td><h:outputText value="#{eventoBean.evento.dataInicio.time}">
								<f:convertDateTime type="both" pattern="dd/MM/yyyy" />
							</h:outputText></td>
					</tr>
					<tr>
						<td><h:outputText value="Data de Término: " /></td>
						<td><h:outputText value="#{eventoBean.evento.dataTermino.time}">
								<f:convertDateTime type="both" pattern="dd/MM/yyyy" />
							</h:outputText></td>
					</tr>
					<tr>
						<td><h:outputText value="Descrição: " /></td>
						<td><h:outputText value="#{eventoBean.evento.descricao}" /></td>
					</tr>
				</table>

			</p:panel>
			<div class="posicao_botao" align="right">
				<p:commandButton value="Voltar"
					onclick="PF('painelConsultarEvento').close(); PF('painelListarEvento').show();"
					type="button" />
				<p:commandButton value="Alterar" update=":formAlterarEvento"
					oncomplete="PF('painelConsultarEvento').close(); PF('painelAlterarEvento').show();"
					styleClass="botao" />
			</div>
		</h:form>
	</p:panel>
</body>
</html>
